<template>
  <el-form :model="dangerForm" label-position="left" class="demo-form-inline m-l-10">
    <el-form-item label="危险源" label-width="120px">
      <el-select class="shadow-lg" v-model="dangerForm.dangerOptions" :disabled="!isEdit" multiple placeholder="请选择危险源(多选)">
        <el-option  v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
    </el-form-item>
    <el-form-item label="动火等级" label-width="120px">
      <el-input class="shadow-lg" v-model="dangerForm.file"></el-input>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
import { ref } from "vue"
const dangerForm = ref({
  danger: '',
  file: '',
  dangerOptions: []
})
interface optionForm {
  name: string[],
  level: string,
  machines: string[],
}
const levelOptions = [{
  label: "一级动火", value: "1"
}, {
  label: "二级动火", value: "2"
}, {
  label: "三级动火", value: "3"
}, {
  label: "四级动火", value: "4"
}
]
const fileOptions = [{
  label: "干粉灭火器", value: "1"
}, {
  label: "消防车", value: "2"
}
]
const options = [
  {
    label: "高处作业",
    value: "高处作业"
  }, {
    label: "动火作业",
    value: "动火作业"
  }, {
    label: "起重作业",
    value: "起重作业"
  }, {
    label: "机械伤害",
    value: "机械伤害"
  },
  {
    label: "用电作业",
    value: "用电作业"
  }, {
    label: "物体打击",
    value: "物体打击"
  }, {
    label: "电气安全",
    value: "电气安全"
  }, {
    label: "受限空间",
    value: "受限空间"
  }, {
    label: "滑跌伤害",
    value: "滑跌伤害"
  }, {
    label: "照明不良",
    value: "照明不良"
  }, {
    label: "触电",
    value: "触电"
  }]

const formInline = ref<optionForm>({
  name: ['1', '2', '3', '4', '5', '6'],
  level: '3',
  machines: ['1']
})
const props = defineProps({
  isEdit: Boolean,
  dangerData: Object
})
watch(() => props.dangerData.dange, (newval, oldval) => {
  let dangerArr = newval.split('、')
  dangerArr = dangerArr.filter(function (item) {
    // 删除空字符串
    return item.trim() != '';
  });
  dangerForm.value.dangerOptions = dangerArr
})
</script>

<style lang="less" scoped>
:deep(.el-tag--info){
  background-color: #ffbe76;
  color: black;
  .el-tag__close{
    color:#6c5ce7;
  }
}
</style>
